import { createFeature } from "@webiny/feature/api";
import { CognitoUserBeforeCreateHandler } from "./UserBeforeCreateHandler.js";
import { CognitoUserBeforeUpdateHandler } from "./UserBeforeUpdateHandler.js";
import { CognitoUserAfterUpdateHandler } from "./UserAfterUpdateHandler.js";
import { CognitoUserAfterDeleteHandler } from "./UserAfterDeleteHandler.js";
import { CognitoConfig, type ICognitoConfig } from "./abstractions.js";

export const SyncWithCognitoFeature = createFeature({
    name: "SyncWithCognitoFeature",
    register(container, config: ICognitoConfig) {
        // Register the CognitoConfig instance
        container.registerInstance(CognitoConfig, config);

        // Register event handlers
        container.register(CognitoUserBeforeCreateHandler);
        container.register(CognitoUserBeforeUpdateHandler);
        container.register(CognitoUserAfterUpdateHandler);
        container.register(CognitoUserAfterDeleteHandler);
    }
});
